package com.czxy.demo01;

/**
 * Created by hp on 2020/1/31.
 */
public class Test14 {
    public static void main(String[] args) {
        String s = "this is a test of java";
        int s1 = getCharNum('s');
        System.out.println("字母s出现的次数"+s1);
        String[] split = s.split("");
        for (int i = 0; i < split.length; i++) {
            if (split[i].equals("test")){
                System.out.println("test的索引为值"+i);
            }
            if (split[i].equals("java")){
                split[i]="JAVASE";
            }
        }
        for (String s2 : split) {
            System.out.print(s2+"");
        }
    }
    public static int getCharNum(char c){
        String s ="this is a test of java";
        int a= 0;
        for (int i = 0; i < s.length(); i++) {
            if (c==s.charAt(i)){
                a++;
            }
        }
        return a;
    }
}
